fix(lsps4): trigger channel open at peer_connected even during reestablish#9
Merged
martinsaposnic merged 1 commit intolsp-0.2.0from Mar 20, 2026
Merged
Conversation
fe2e09a to
eecf53e
Compare
…blish When an HTLC arrives for an offline peer, htlc_intercepted stores it and sends a webhook. When the peer reconnects, peer_connected deferred all processing if channels existed but weren't usable yet (reestablish in progress). Later, process_pending_htlcs found insufficient capacity but assumed a channel open was already in flight - nobody ever opened the channel. Fix: call process_htlcs_for_peer even when channels aren't usable. calculate_htlc_actions skips non-usable channels, so if existing capacity is insufficient it returns new_channel_needed_msat and execute_htlc_actions emits OpenChannel. No premature forwarding occurs since the forwards list is empty (no usable channels). The actual HTLC forwards happen via channel_ready once the new channel is established.
d7b97a7 to
2252def
Compare
kitaebot
approved these changes
Mar 20, 2026
martinsaposnic
added a commit
to moneydevkit/ldk-node
that referenced
this pull request
Mar 20, 2026
…en fix Updates rust-lightning rev to include moneydevkit/rust-lightning#9: trigger OpenChannel at peer_connected even during reestablish, fixing stuck HTLC loop when existing channel capacity is insufficient.
1 task
amackillop
pushed a commit
to moneydevkit/ldk-node
that referenced
this pull request
Mar 20, 2026
…en fix (#13) Updates rust-lightning rev to include moneydevkit/rust-lightning#9: trigger OpenChannel at peer_connected even during reestablish, fixing stuck HTLC loop when existing channel capacity is insufficient.
amackillop
added a commit
that referenced
this pull request
Mar 22, 2026
Channel usability (is_usable) was checked at four separate points: htlc_intercepted, peer_connected, process_pending_htlcs, and calculate_htlc_actions_for_peer. Each had its own deferral logic, and they had to coordinate (the timer skipped channel opens assuming peer_connected already handled them). This coordination broke: PR #9 made peer_connected call process_htlcs_for_peer during reestablish, which saw an empty capacity map because non-usable channels were filtered out, and emitted a spurious OpenChannel on every reconnect with a pending HTLC. Move the usability check to execute_htlc_actions, right before forward_intercepted_htlc. If no usable channel exists, the forward is skipped and the HTLC stays in store for the timer to retry. htlc_intercepted, peer_connected, and process_pending_htlcs now all call process_htlcs_for_peer unconditionally. calculate_htlc_actions_for_peer includes all channels in the capacity map regardless of is_usable, so it correctly sees that a reestablishing channel has sufficient capacity and does not request a spurious new channel. Change the pre-forward guard from is_peer_connected to has_usable_channel, which covers the disconnect+reconnect race where the peer is connected but the channel has not finished reestablishing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
htlc_interceptedstores it and sends a webhook. The peer reconnects, butpeer_connecteddeferred all processing because channels weren't usable yet (reestablish in progress). Later,process_pending_htlcsfound insufficient capacity but assumed a channel open was "already in flight" - nobody ever opened one. The HTLC would loop until expiry (45s) and fail.process_htlcs_for_peereven when channels aren't usable.calculate_htlc_actionsskips non-usable channels, so it correctly returnsnew_channel_needed_msatand emitsOpenChannel. No premature forwarding occurs since the forwards list is empty (no usable channels). Actual HTLC forwards happen viachannel_readyonce the new channel is established.Test plan